﻿using AutoRegistDependency.Attributes;
using Core.Helper;
using Microsoft.Extensions.Logging;
using Models.Entities.SystemEntities;
using Repositories.Base;
using Services.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Services.Sys
{
    [Component]
    public class DictionaryService : BaseService<DictionaryInfo>, IDictionaryService
    {
        public DictionaryService(IBaseRepository<DictionaryInfo> repository, ILogger<DictionaryInfo> logger) : base(repository, logger)
        {
        }

        public List<DictionaryInfo> GetTree()
        {
            var list = repository.GetList(t => true);
            return ExpressionHelper.ConvertToTreeList(list, t => t.ParentId == null || t.ParentId == 0, t => t.Id == t.ParentId);
        }
    }
}
